﻿using Cysharp.Threading.Tasks;
using System;
using UnityEngine;

public static partial class SkillAction // effect 特效相关
{
    /// <summary>
    /// 播放动画
    /// </summary>
    public static void PlayAnim(UnitEntityBase entity, string clipName)
    {
        entity.animator.Play(clipName);
    }

    /// <summary>
    /// 生成特效
    /// </summary>
    public static void SpawnVFX(SkillBase skill, Vector2 positionOffset)
    {
        var vfx = skill.effectPool.Rent();
        var vfxTrans = vfx.gameObject.transform;
        var entity = skill.entity;
        var offset = positionOffset * entity.animator.direction;
        var point = (Vector2)entity.transform.position + entity.physics.box.offset + offset;
        vfxTrans.position = point;
        vfxTrans.localScale = entity.animator.direction;
        vfxTrans.parent = entity.transform.parent;
        vfxTrans.SetAsLastSibling();
        vfx.SetData(skill);
    }
}